package com.platform.service.impl;

import com.platform.dao.EmceeAdPositionDao;
import com.platform.entity.EmceeAdPositionEntity;
import com.platform.service.EmceeAdPositionService;
import com.platform.utils.ShiroUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.List;
import java.util.Map;

/**
 * Service实现类
 *
 * @author lipengjun
 * @email 939961241@qq.com
 * @date 2017-08-19 12:02:42
 */
@Service("EmceeAdPositionService")
public class EmceeAdPositionServiceImpl implements EmceeAdPositionService {
    @Autowired
    private EmceeAdPositionDao adPositionDao;

    @Override
    public EmceeAdPositionEntity queryObject(Integer id) {
        return adPositionDao.queryObject(id);
    }

    @Override
    public List<EmceeAdPositionEntity> queryList(Map<String, Object> map) {
        Long userId = ShiroUtils.getUserId();
        if(userId == 1){
            map.put("createUser", null);
        }else {
            map.put("createUser", userId);
        }
        return adPositionDao.queryList(map);
    }

    @Override
    public int queryTotal(Map<String, Object> map) {
        return adPositionDao.queryTotal(map);
    }

    @Override
    public int save(EmceeAdPositionEntity adPosition) {
        adPosition.setCreateUser(ShiroUtils.getUserId().intValue());
        adPosition.setCreateTime(new Date());
        return adPositionDao.save(adPosition);
    }

    @Override
    public int update(EmceeAdPositionEntity adPosition) {
        return adPositionDao.update(adPosition);
    }

    @Override
    public int delete(Integer id) {
        return adPositionDao.delete(id);
    }

    @Override
    public int deleteBatch(Integer[] ids) {
        return adPositionDao.deleteBatch(ids);
    }
}
